import 'package:flutter/material.dart';
import 'package:get/get.dart';

import '../../../../common/routers/routes.dart';
import '../widgets/conversation_list_view.dart';
import 'index.dart';

class ConversationPickerPage extends GetView<ConversationPickerController> {
  const ConversationPickerPage({Key? key}) : super(key: key);

  static Future<dynamic> open() async {
    return await Get.toNamed(O2OARoutes.homeImChatPicker);
  }

  @override
  Widget build(BuildContext context) {
    return GetBuilder<ConversationPickerController>(
      builder: (_) {
        return Scaffold(
            appBar: AppBar(title: Text("im_chat_conversation_picker_title".tr)),
            body: SafeArea(
                child: Container(
              color: Theme.of(context).scaffoldBackgroundColor,
              child: Obx(() {
                return ConversationListView(
                  controller.state.conversationList.toList(),
                  onTapConversation: (info) =>
                      controller.chooseConversation(info),
                );
              }),
            )));
      },
    );
  }
}
